import json
import os

from framework.httpRequest import HttpRequest
from model.loginInterface import Login
from utils.readFile import ReadFile


class LoginImplApi(Login):

	def loginIn(self):
		httpRequest = HttpRequest()
		#执行用例前，修改环境配置文件，将环境设置为将要执行用例的环境
		httpRequest.host = (ReadFile.readEnvConfigYaml((os.path.dirname(os.path.dirname(os.path.abspath(__file__)))+"\\config\\config.yml"))['environment'])
		httpRequest.path = '/wx/auth/login'
		httpRequest.method = 'post'
		httpRequest.type = 'json'
		httpRequest.bodyData = {"username":self.username,"password":self.password}
		response = httpRequest.send()
		return response